package com.anquing.ssodemo;

import com.anquing.ssodemo.redisService.RedisService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Date;

@RestController
@SpringBootApplication
public class ServerApplication {

	Logger log = LoggerFactory.getLogger(this.getClass());


	public static void main(String[] args) {
		SpringApplication.run(ServerApplication.class, args);
	}

	@RequestMapping("/helloServer")
	public String hello(HttpServletRequest request){
		HttpSession session = request.getSession();
		String id = session.getId();
		log.info("/helloServer，SessionId="+id);
		Boolean isLogin = (Boolean)session.getAttribute("isLogin");
		if(isLogin!=null&&isLogin){
			System.out.println(isLogin);
		}
		RedisService.set("helloServer", "helloServer" + new Date());
		return "helloServer";
	}
}
